import pandas as pd
import matplotlib.pyplot as plt

# 设置图片清晰度
plt.rcParams['figure.dpi'] = 300

# 设置 matplotlib 支持中文
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
plt.rcParams['axes.unicode_minus'] = False

# 读取数据
file_path = 'FhjlViewDD.xlsx'
data = pd.read_excel(file_path)

# 按发货地分组计算发货总量
shipment_by_location = data.groupby('发货地')['净重'].sum()

# 绘制柱状图
plt.figure(figsize=(10, 6))
shipment_by_location.plot(kind='bar')
plt.title('6月份各发货地发货总量')
plt.xlabel('发货地')
plt.ylabel('发货总量')
plt.xticks(rotation=45)
plt.tight_layout()

# 保存图片
plt.savefig('(d)6月份各发货地发货总量统计图.png')
plt.close()